<?
include_once("database_info.php");
include_once("common.php");
connect_select_Test("sermons");
if ($_POST['key'] == crypt("He1sR1sen", $_POST['key'])){
	$order = ($_POST['order'] ? $_POST['order'] : "id");
	$direction = ($_POST['direction'] ? $_POST['direction'] : "Asc");
	$limit = ($_POST['limit'] ? $_POST['limit'] : "25");
	$search = ($_POST['searchString'] ? "WHERE `".$_POST['searchField']."` LIKE '%".$_POST['searchString']."%'" : null);
	$result = mysql_query("SELECT * FROM `".$_POST['table']."` ".$search." ORDER BY `".$order."` ".$direction." LIMIT 0,".$limit);
	if (mysql_num_rows($result) != 0){
		for ($x=0;$x<mysql_num_rows($result);$x++){
			echo ($x != 0) ? "|row|" : "";
			$row = mysql_fetch_row($result);
			echo implode("|cell|", $row);
		}
	} else {
		echo "empty";
	}
}
?>